GBML manual / Constants

SPRITE_DRUM

A lens fixed to the middle of the screen, and the sprite slides through it: full size in the middle, narrower and shorter toward the top and bottom of the lens, gone at its edge - like a picture on a drum that is rolling past you. Move the sprite up or down and it rolls. depth is how tight the lens is: 1 is as tall as the screen, 6 is tight.

Works differently on Game Boy - The Game Boy narrows the picture on some lines by moving its two sprite pieces toward each other (the middle is covered, not squeezed), a drum or a band hides it outside the lens; 16 pixels wide at most, one picture at a time; the size is not used.

Works differently on Game Boy Color - The Game Boy Color narrows the picture on some lines by moving its two sprite pieces toward each other (the middle is covered, not squeezed), a drum or a band hides it outside the lens; 16 pixels wide at most, one picture at a time; the size is not used.

Sega Genesis: not built yet

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

SPRITE_DRUM: constant

Description

Names the drum, a shape for draw_sprite_3d and draw_sprite_3d_scaled. The other three shapes put the curve on the picture, and it goes wherever the sprite goes. The drum puts it on the screen: there is a lens in the middle of the picture, and sprites slide through it. A sprite whose middle is in the middle row is full size and flat. As it slides up or down it gets narrower and shorter, and at the edge of the lens it closes up to nothing, like a picture on a drum that is rolling past you. It is the sprite's own name for TEXT_DRUM, and works the same way.

A real capture, nine frames that play one after another - a striped lighthouse sliding down the screen through a lens in its middle. At the top it is a thin, short sliver that grows as it comes down, it is full size in the middle, and it shrinks away again toward the bottomA real capture, nine frames that play one after another - a striped lighthouse sliding down the screen through a lens in its middle. At the top it is a thin, short sliver that grows as it comes down, it is full size in the middle, and it shrinks away again toward the bottom
A real capture, nine frames that play one after another - a striped lighthouse sliding down the screen through a lens in its middle. At the top it is a thin, short sliver that grows as it comes down, it is full size in the middle, and it shrinks away again toward the bottom

The same call every frame, with only y changing: the lighthouse rolls down through the lens. Nine real pictures from a Game Boy Advance ROM, played in a loop. A tall striped lighthouse stands in for the example's spr_doc_tower. A viewer that does not play it shows only the first frame.

So the thing you animate is the sprite's own y. Draw it low and move it up and it rises out of the floor, growing as it comes. Park its middle on the middle row (row 80 of the 160 pixel screen) and it stands there looking completely ordinary. Push it on and it dwindles away over the top. That is what makes it good for a boss that arrives, a logo that rolls in, or a picture that recedes into the distance as a scene begins.

A real capture - six pictures of a striped lighthouse at six heights on the screen, from near the top to below the middle. Near the top it is small and squashed, and it grows as it gets nearer the middle rowA real capture - six pictures of a striped lighthouse at six heights on the screen, from near the top to below the middle. Near the top it is small and squashed, and it grows as it gets nearer the middle row
A real capture - six pictures of a striped lighthouse at six heights on the screen, from near the top to below the middle. Near the top it is small and squashed, and it grows as it gets nearer the middle row

Six frames of the roll, with the row the sprite's middle is on written under each (row 80 is the middle of the screen).

A row of the picture that is far from the middle of the screen is drawn smaller than one near the middle, and the size falls off as the square of the distance, so it is nearly full size for a good way either side of the middle and then drops away quickly toward the edge. The numbers are made for you.

Depth: how tight the lens is

For the drum, depth goes from 1 to 6, not 1 to 3 like the other sprite shapes. It is not a curve on the picture at all: it sets how tall the lens is, in rows above and below the middle of the screen, so it does not matter what the picture is.

depththe lens reacheswhat it is like
1100 rows each waytaller than the screen: a sprite is only squashed a little near the top and the bottom
284 rows
372 rowsa sprite is clearly smaller by the time it is half way to the edge
462 rows
554 rows
646 rowsa tight lens: a sprite is full size only close to the middle and has closed up well before the edge of the screen
A real capture - a striped lighthouse held 20 rows below the middle of the screen while the lens gets tighter, from depth 1 to depth 6. The same lighthouse gets smaller and smaller because it is farther and farther toward the edge of the lensA real capture - a striped lighthouse held 20 rows below the middle of the screen while the lens gets tighter, from depth 1 to depth 6. The same lighthouse gets smaller and smaller because it is farther and farther toward the edge of the lens
A real capture - a striped lighthouse held 20 rows below the middle of the screen while the lens gets tighter, from depth 1 to depth 6. The same lighthouse gets smaller and smaller because it is farther and farther toward the edge of the lens

The same sprite, held in one place 20 rows below the middle, at each depth. The sprite has not moved: the lens has.

A number below 1 draws the plain, flat sprite and costs nothing, and a number above 6 is read as 6.

What to know before you use it

Example

draw_sprite_3d(spr_doc_tower, x, y, 0, SPRITE_DRUM, 3);

The tower in a lens of depth 3. Where it is on the screen decides how big it is: change y and it rolls.

draw_sprite_3d(spr_doc_tower, x, y + wave(-60, 60, 180, 0), 0, SPRITE_DRUM, 3);

A tower that rolls up and down over and over (one trip up and back every three seconds), shrinking as it goes toward either edge of the lens.

See also: draw_sprite_3ddraw_sprite_3d_scaledTEXT_DRUMSPRITE_BULGEdraw_sprite_ripple